﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BoriPeter.FitnessJournal8.Models
{
    public class FoodEntry : ModelBase
    {
        #region Id
        private int id;
        /// <summary>
        /// the unique identifier of the food diary entry.
        /// </summary>
        public int Id
        {
            get
            {
                return this.id;
            }

            set
            {
                this.id = value;
                NotifyOfPropertyChange("Id");
            }
        }
        #endregion

        #region Date
        private DateTime date;
        public DateTime Date
        {
            get
            {
                return this.date;
            }

            set
            {
                this.date = value;
                NotifyOfPropertyChange("Date");
            }
        }
        #endregion

        #region ServingId
        private int servingId;
        /// <summary>
        /// the unique serving identifier, indicating the serving size nominated for the food diary entry.
        /// </summary>
        public int ServingId
        {
            get
            {
                return this.servingId;
            }

            set
            {
                this.servingId = value;
                NotifyOfPropertyChange("ServingId");
                if ((Food != null)  && (Food.Servings != null))
                    SelectedServing = Food.Servings.Where(s => s.Id == servingId).FirstOrDefault();
            }
        }
        #endregion

        #region SelectedServing
        private Serving selectedServing;
        public Serving SelectedServing
        {
            get
            {
                return this.selectedServing;
            }

            set
            {
                this.selectedServing = value;
                NotifyOfPropertyChange("SelectedServing");
            }
        }
        #endregion

        #region NumberOfUnits
        private decimal numberOfUnits;
        /// <summary>
        /// the number of units of the standard serving size consumed.
        /// </summary>
        public decimal NumberOfUnits
        {
            get
            {
                return this.numberOfUnits;
            }

            set
            {
                this.numberOfUnits = value;
                NotifyOfPropertyChange("NumberOfUnits");
            }
        }
        #endregion

        #region EntryName
        private string entryName;
        /// <summary>
        ///  a description of the food item as entered by the user; typically the name of the food. E.G.: "Instant Oatmeal".
        /// </summary>
        public string EntryName
        {
            get
            {
                return this.entryName;
            }

            set
            {
                this.entryName = value;
                NotifyOfPropertyChange("EntryName");
            }
        }
        #endregion

        #region Meal
        private string meal;
        public string Meal
        {
            get
            {
                return this.meal;
            }

            set
            {
                this.meal = value;
                NotifyOfPropertyChange("Meal");
            }
        }
        #endregion

        #region Food
        private Food food;
        public Food Food
        {
            get
            {
                return this.food;
            }

            set
            {
                this.food = value;
                NotifyOfPropertyChange("Food");
                if ((ServingId != 0) && (Food.Servings != null))
                    SelectedServing = Food.Servings.Where(s => s.Id == servingId).FirstOrDefault();
            }
        }
        #endregion
    }
}
